package com.welove.activity;

import com.welove.R;
import com.welove.activity.login.LoginActivity;
import com.welove.widget.MyGridView;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.ViewFlipper;

public class FriendInfoActivity extends BaseActivity implements OnClickListener,OnItemClickListener{
	private static final String TAG=FriendInfoActivity.class.getSimpleName();
	
	

	private ImageView fridinfo_iv_image;
	private TextView fridinfo_tv_nick,fridinfo_tv_vip,fridinfo_tv_province,fridinfo_tv_city,fridinfo_tv_age,fridinfo_tv_height,
					 fridinfo_tv_edu,friendinfo_tv_declare;
	private Button friendinfo_btn_sendmsg;
	private MyGridView friendinfo_gv_photo;
	private RelativeLayout friendinfo_relative_id,friendinfo_relative_age,friendinfo_relative_height,friendinfo_relative_local,friendinfo_relative_edu,friendinfo_relative_income;
	private TextView friendinfo_tv_id,friendinfo_tv_age,friendinfo_tv_height,friendinfo_tv_local,friendinfo_tv_edu,friendinfo_tv_income;
	
	private boolean isLogin;
	
	@Override
	protected void installViews() {
		setContentView(R.layout.activity_friendinfo);
		initView();
	}

	private void initView()
	{
		//会员头像、昵称、年龄、地区、身高、学历、是否会员等信息
		fridinfo_iv_image=initIv(R.id.fridinfo_iv_image);
		fridinfo_tv_nick=initTv(R.id.fridinfo_tv_nick);
		fridinfo_tv_vip=initTv(R.id.fridinfo_tv_vip);
		fridinfo_tv_province=initTv(R.id.fridinfo_tv_province);
		fridinfo_tv_city=initTv(R.id.fridinfo_tv_city);
		fridinfo_tv_age=initTv(R.id.fridinfo_tv_age);
		fridinfo_tv_height=initTv(R.id.fridinfo_tv_height);
		fridinfo_tv_edu=initTv(R.id.fridinfo_tv_edu);
		friendinfo_tv_declare=initTv(R.id.friendinfo_tv_declare);
		
		//发送私信按钮
		friendinfo_btn_sendmsg=initBtn(R.id.friendinfo_btn_sendmsg);
		
		
		//会员相册
		friendinfo_gv_photo=(MyGridView)initGv(R.id.friendinfo_gv_photo);
		
		
		//会员基本信息
		friendinfo_relative_id=initRelative(R.id.friendinfo_relative_id);
		friendinfo_relative_age=initRelative(R.id.friendinfo_relative_age);
		friendinfo_relative_height=initRelative(R.id.friendinfo_relative_height);
		friendinfo_relative_local=initRelative(R.id.friendinfo_relative_local);
		friendinfo_relative_edu=initRelative(R.id.friendinfo_relative_edu);
		friendinfo_relative_income=initRelative(R.id.friendinfo_relative_income);
		
		friendinfo_tv_id=initTv(R.id.friendinfo_tv_id);
		friendinfo_tv_age=initTv(R.id.friendinfo_tv_age);
		friendinfo_tv_height=initTv(R.id.friendinfo_tv_height);
		friendinfo_tv_local=initTv(R.id.friendinfo_tv_local);
		friendinfo_tv_edu=initTv(R.id.friendinfo_tv_edu);
		friendinfo_tv_income=initTv(R.id.friendinfo_tv_income);
	}
	
	@Override
	protected void registerEvents() {
		
		friendinfo_btn_sendmsg.setOnClickListener(this);
		friendinfo_gv_photo.setOnItemClickListener(this);
		
		
	}
	
	@Override
	protected void initTitleBar() {
		super.initTitleBar();
		
		
		mTitleBar.titlebar_tv_center.setText("一生姻缘");
		mTitleBar.titlebar_btn_right.setVisibility(ViewFlipper.GONE);
		
	}
	
	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		switch (v.getId()) {
		case R.id.friendinfo_btn_sendmsg:
			//判断是否登录
			isLogin=getBoolPref("UserInfo","login_status");
			if(!isLogin)
			{
				//如果没登陆进入登录界面
				Intent toLgInt=new Intent(FriendInfoActivity.this,LoginActivity.class);
				toLgInt.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
				startActivity(toLgInt);
			}
			else {
				//如果登陆进入私信聊天界面
//				Intent tochatInt=new Intent(FriendInfoActivity.this,ChatActivity.class);
//				tochatInt.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
//				startActivity(tochatInt);
			}
			break;

		default:
			break;
		}
	}

	@Override
	public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
		// TODO Auto-generated method stub
		Intent tophotoInt=new Intent(FriendInfoActivity.this,FriendInfoPhotoActivity.class);
		tophotoInt.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
		startActivity(tophotoInt);
	}
}
